<template>
  <el-menu :collapse="getCollapseStatus" :router="true">
    <Menu :menuList="menuNodes" />
  </el-menu>
</template>
<script setup lang="ts">
import Menu from './menu.vue'
// import type { MenuData, MenuChildrenData } from './type/type'
import menuList from '@/config/menuConfig.ts'
// import { useRoute } from 'vue-router'
// const route = useRoute()
import useAppstore from '@/store/modules/app.ts'

const { getCollapseStatus } = useAppstore()

// const hashAuth = (item: MenuData) => {
//   const { index, isPublic } = item
//   if (isPublic || menuList?.indexOf(index) != -1) {
//     return true
//   } else if (item.children) {
//     return !!item.children.find((child: MenuChildrenData) => menuList.indexOf(child.index) != -1)
//   } else {
//     return false
//   }
// }

let menuNodes: any[] = []
const getMenuNodes = () => {
  menuList.forEach((item) => {
    if (!item.children) {
      menuNodes.push(item)
    } else {
      let tempArr = []
      item.children.forEach((i) => {
        tempArr.push(i)
      })
      let obj = { ...item, children: tempArr }
      if (obj && obj.children && obj.children.length) menuNodes.push(obj)
    }
  })
}
getMenuNodes()
</script>

<style scoped lang="less">
.logoemun {
  height: 100%;
}
</style>
